package com.cdd.mvc;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AppQuartzService {

    @Autowired
    private AppQuartzDao appQuartzDao;

    public void insertJob(AppQuartz appQuartz){
        appQuartzDao.save(appQuartz);
    }


    public AppQuartz queryOne(Integer quartzId){
        return appQuartzDao.getOne(quartzId);
    }

    public void deleteById(Integer quartzId){
        appQuartzDao.deleteById(quartzId);
    }

    /**
     * repository.save()的逻辑是：
     * 如果不存在Entity对应的数据记录则执行插入操作，否则则执行更新操作.
     * 在执行更新操作之前，此方法还会执行一步查询操作
     * @param appQuartz
     */
    public void updateAppQuartzSer(AppQuartz appQuartz){

//        appQuartzDao.save(appQuartz);
        appQuartzDao.saveAndFlush(appQuartz);
    }
}
